package com.xjrsoft.module.customer.erp_model.eRP_Disk.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xjrsoft.common.page.ConventPage;
import com.xjrsoft.common.page.PageOutput;
import com.xjrsoft.common.result.Response;
import com.xjrsoft.common.utils.DataTransUtil;
import com.xjrsoft.core.tool.utils.BeanUtil;
import com.xjrsoft.core.tool.utils.Func;
import com.xjrsoft.module.base.service.IXjrBaseCodeRuleService;
import com.xjrsoft.module.customer.erp_model.eRP_Disk.dto.ErpStockinventoryListDto;
import com.xjrsoft.module.customer.erp_model.eRP_Disk.dto.UpdateInventorDtoList;
import com.xjrsoft.module.customer.erp_model.eRP_Disk.dto.UpdateInventoryDto;
import com.xjrsoft.module.customer.erp_model.eRP_Disk.vo.ErpStockinventoryListVo;
import com.xjrsoft.module.customer.erp_model.eRP_Disk.service.IErpStockinventoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 *  控制器
 *
 * @author pp
 * @since 2021-11-10
 */
		@RestController
		@AllArgsConstructor
		@RequestMapping("/erp_disk")
		@Component("ErpStockinventory")
		@Api(value = "盘盈审核", tags = "盘盈审核接口")
		public class ErpStockinventoryController {


		private final IErpStockinventoryService erpStockinventoryService;

		private final IXjrBaseCodeRuleService codeRuleService;


	public List<Map<String, Object>> loadReportData(String dsName, String datasetName, Map<String, Object> parameters) {
		return erpStockinventoryService.loadReportData();
	}

		/**
		 * 自定义分页
		 */
		@GetMapping
		@ApiOperation(value = "分页", notes = "传入erpStockinventory")
		public Response<PageOutput<ErpStockinventoryListVo>> getPageList(ErpStockinventoryListDto listDto) {
		IPage<ErpStockinventoryListVo> page = erpStockinventoryService.getListInfo(listDto);
		List<ErpStockinventoryListVo> records = BeanUtil.copyList(page.getRecords(), ErpStockinventoryListVo.class);
		// 转换列表数据
		DataTransUtil.transListShowData(records);
		// 工作流数据处理
		//FlowableUtil.systemFormList(records, SecureUtil.getModuleId());
		return Response.ok(ConventPage.getPageOutput(page.getTotal(), records));
		}
		@PostMapping("/updateInventory")
		@ApiOperation(value = "审核", notes = "传入erpStockinventory")
		public Response updateInventory(@RequestBody UpdateInventorDtoList updateInventoryDto)
		{
		List<UpdateInventoryDto> updateInventoryDtos = updateInventoryDto.getUpdateInventoryDtos();
		return Response.ok(erpStockinventoryService.updateInventory(updateInventoryDtos));
		}


		}

